package com.itheima.stock.controller;

import com.itheima.stock.common.domain.*;
import com.itheima.stock.pojo.StockBusiness;
import com.itheima.stock.service.StockService;
import com.itheima.stock.vo.R;
import com.itheima.stock.vo.req.PageResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/api/quot")
@CrossOrigin
public class StockController {
    @Autowired
    private StockService stockService;

    @GetMapping("/stock/business/all")
    public List<StockBusiness> getAllBusiness() {
        return stockService.getAllStockBusiness();
    }

    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> getInnerMarketInfos() {
        return stockService.getInnerMarketInfos();
    }

    @GetMapping("/sector/all")
    public R<List<StockBlockDomain>> getStockBlockInfo() {
        return stockService.getStockBlockInfo();
    }

    @GetMapping("/stock/increase")
    public R<List<StockUpdownDomain>> getStockInfoByIncrease() {
        return stockService.getStockInfoByIncrease();
    }

    @GetMapping("/stock/all")
    public R<PageResult<StockUpdownDomain>> getStockByPage(@RequestParam(required = false, defaultValue = "1") Integer page,
                                                           @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        return stockService.getStockByPage(page, pageSize);
    }

    @GetMapping("/stock/updown/count")
    public R<Map> getStockUpdownCount() {
        return stockService.getStockUpdownCount();
    }

    @GetMapping("/stock/tradevol")
    public R<Map<String, List>> getStockCompareTradeVol() {
        return stockService.getStockCompareTradeVol();
    }

    @GetMapping("/stock/updown")
    public R<Map> getStockUpDown(){
        return stockService.stockUpDownScopeCount();
    }
    @GetMapping("/stock/screen/time-sharing")
    public R<List<Stock4MinuteDomain>> stockScreenTimeSharing(String code){
        return stockService.stockScreenTimeSharing(code);
    }
    @RequestMapping("/stock/screen/dkline")
    public R<List<Stock4EvrDayDomain>> getDayKLinData(@RequestParam("code") String stockCode){
        return stockService.stockCreenDkLine(stockCode);
    }
}
